const fs = require('fs');
let text;

//创建可读流
let readerStream = fs.createReadStream('input.txt');

//设置编码
readerStream.setEncoding('utf-8');

//处理流事件
readerStream.on('data',function (datatext) {
    text += datatext;
});
readerStream.on('end',function () { 
    console.log(text);
});
readerStream.on('error',function(err){
    console.log(err.stack);
    console.log('读取失败!')
});
console.log('程序执行完毕！');

